<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
  <script>
      //阶乘
      function factorial(n){
          let sum = 1;
          for (let i = 1; i <= n; i++) {
                sum *= i;
          }
          return sum;
      }

      console.log(factorial(4));
  </script>
</body>
</html>